<!-- 回单 -->
<template>
  <el-form ref="ruleForm"
           :model="ruleForm"
           label-width="90px">
    <el-form-item label="回单日期">
      <el-date-picker v-model="ruleForm.receiptTime"
                      align="right"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      default-time="23:59:59"></el-date-picker>
      <!-- :default-value="new Date()" -->
    </el-form-item>
    <el-form-item label="异常">
      <el-radio v-model="ruleForm.exceptionStatus"
                :label="0">无</el-radio>
      <el-radio v-model="ruleForm.exceptionStatus"
                :label="1">补单</el-radio>
    </el-form-item>
    <span>如需上传回单照片，请点击
      <el-button type="text"
                 @click="uploadPic">上传照片</el-button>
    </span>
    <!-- 按钮 -->
    <div class="footer-btn">
      <el-button type="primary"
                 :loading="loading"
                 @click="submit">{{
          loading ? "提交中 ..." : "确 定"
        }}</el-button>
    </div>
  </el-form>
</template>

<script>
import orderApi from '@/api/modules/orderNew'
export default {
  name: 'OrderReceipt',
  props: {
    value: {
      type: Object,
      default: () => { }
    }
  },
  data () {
    return {
      ruleForm: {
        receiptTime: this.$moment(new Date()).format("YYYY-MM-DD 23:59:59"),
        exceptionStatus: 0,
      },
      loading: false
    }
  },
  computed: {
    row () {
      return this.value;
    },
  },
  methods: {
    uploadPic () {

    },
    submit () {
      this.loading = true;
      this.timer = setTimeout(() => {
        setTimeout(() => {
          this.handelSave();
        }, 400);
      }, 1500);
    },
    async handelSave () {
      let params = {
        orderId: this.row.orderId,
        ...this.ruleForm
      }
      await orderApi.receipt(params)
      this.loading = false;
      this.$message({ type: "success", message: "操作成功" });
      this.$emit("confirm");
    }
  }
}
</script>

<style scoped>
.footer-btn {
  text-align: center;
  padding-top: 10px;
}
</style>